package Thread;


public class ThreadDemo26 {

    public static void main(String[] args) throws InterruptedException {
        int count = 10;
        Object lock1 = new Object();
        Object lock2 = new Object();
        for (int i = 0; i < 10; i++) {
            Thread t2 = new Thread(()->{
                synchronized (lock1) {
                    try {
                        lock1.wait();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
                System.out.print("B");
                synchronized (lock2) {
                    lock2.notify();
                }
            });
            Thread t3 = new Thread(()->{
                synchronized (lock2) {
                    try {
                        lock2.wait();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
                System.out.print("C");
            });
            Thread t1 = new Thread(()->{
                System.out.print("A");
                try {
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                synchronized (lock1) {
                    lock1.notify();
                }
            });
            t1.start();
            t2.start();
            t3.start();
            t1.join();
            t2.join();
            t3.join();
            System.out.println();
            Thread.sleep(100);
            count--;
        }
    }

}
